# GPL3 or later

# Program to have manual input from the computer

import os
import json
import time
from ui import *
import youtube
from getpass import getpass

import commands

signed = ""
    


while True:

    
    
    c = input(clr["tbgr"]+signed+": "+clr["norm"])

    username = signed
    
    with open('stuff.json') as json_file: 
        stuff = json.load(json_file)

    if not c and not username:
        continue
        
    if not username and c and "@" not in c:
        print("   Login first!")
        continue

    # Login
    elif c.startswith("@"):
        if c in stuff.get("users", {}):
            if stuff.get("users", {}).get(c, {}).get("password"):
                password = getpass("Password: ")
                if password != stuff.get("users", {}).get(c, {}).get("password"):
                    print("Wrong Password!")
                    continue
                
            signed = c
                
    
    elif signed and not c:
        signed = ""

    else:
        answer = commands.execute(username, c)
        print("        [  "+clr["tbbu"]+"SENDING"+clr["norm"]+" ] "+answer.replace("\n", "\n                  "))
            
    
